package leetcode.top100;

import org.junit.Test;

/**
 * @author ：zsy
 * @date ：Created 2022/12/5 8:22 PM
 * @description：
 */
public class _048_旋转图像 {
    @Test
    public void test() {

    }

    class Solution {
        public void rotate(int[][] matrix) {
            int n = matrix.length;
            // 水平翻转
            for (int i = 0; i < n / 2; i++) {
                for (int j = 0; j < n; j++) {
                    int tmp =  matrix[i][j];
                    matrix[i][j] = matrix[n - 1 - i][j];
                    matrix[n - 1 - i][j] = tmp;
                }
            }
            // 主对角线翻转
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < i; j++) {
                    int tmp = matrix[i][j];
                    matrix[i][j] = matrix[j][i];
                    matrix[j][i] = tmp;
                }
            }
        }
    }
}
